package com.nowcoder.community.config;

import com.google.code.kaptcha.Producer;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * <p>Title: KaptchaConfig</p>
 * <p>author 12427</p>
 *
 * @version ver1.0
 * @date 2022/7/12 22:24
 */
@Configuration
public class KaptchaConfig {

    @Bean
    public Producer kaptchaProducer(){
        Properties properties = new Properties() ;
        properties.setProperty("kaptcha.image.width" , "100") ;
        properties.setProperty("kaptcha.image.height" , "40") ;
        properties.setProperty("kaptcha.textproducer.fFont.size" , "30") ;
        properties.setProperty("kaptcha.textproducer.font.color" , "black") ;
        properties.setProperty("kaptcha.textproducer.char.string" ,"0123456789ABCDEEGHIJKLMNOPORSTUVWXYZ") ;
        properties.setProperty("kaptcha.textproducer.char.length" , "4") ;
        properties.setProperty("kaptcha.noise.impl" , "com.google.code.kaptcha.impl.NoNoise") ;





        DefaultKaptcha kaptcha = new DefaultKaptcha() ;
        Config config = new Config(properties) ;
        kaptcha.setConfig(config);
        return kaptcha ;

    }
}
